﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SGArchiveSystem7xDB;
using SGArchiveSystem7xDB.Linq;

namespace SGArchiveSystem7x.Models
{
    /// <summary>
    /// 档案树菜单
    /// </summary>
    public class CArchiveTreeModel
    {
        public T_ArchiveType archieType { get; set; }
        public List<T_ArchiveTree> archiveTree { get; set; }
        /// <summary>
        /// 建立档案树菜单
        /// </summary>
        /// <param name="listType"></param>
        /// <param name="listTree"></param>
        /// <returns></returns>
        public static List<CArchiveTreeModel> Create_ArchiveTree(List<T_ArchiveType> listType, List<T_ArchiveTree> listTree)
        {
            List<CArchiveTreeModel> list = new List<CArchiveTreeModel>();
            foreach(var n in listType)
            {
                CArchiveTreeModel cn = new CArchiveTreeModel();
                cn.archieType = n;
                cn.archiveTree = new List<T_ArchiveTree>();
                foreach(var nn in listTree)
                {
                    if(n.ATYPE_ID == nn.AR_TYPEID)
                    {
                        cn.archiveTree.Add(nn);
                        continue;
                    }
                }
                list.Add(cn);
            }
            return list;
        }
    }
}